package com.jz.community.moduleshoppingguide.nearshop.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.moduleshoppingguide.nearshop.bean.CategoriesBean;
import com.jz.community.moduleshoppingguide.nearshop.bean.ShopDownStairsBean;
import com.jz.community.moduleshoppingguide.nearshop.model.NearShopModel;
import com.jz.community.moduleshoppingguide.nearshop.model.NearShopModelImp;
import com.jz.community.moduleshoppingguide.nearshop.ui.NearShopView;

public class NearShopPresenter extends BaseLifeCyclePresent<NearShopView.View> implements NearShopView.Presenter {


    private NearShopModel nearShopModel;
    private NearShopView.View view;

    public NearShopPresenter(NearShopView.View view) {
        this.view = view;
        this.nearShopModel = new NearShopModelImp(view.getContext());
    }

    @Override
    public void showShopCategorys(String filter) {

        nearShopModel.showShopCategorys(filter, new OnLoadListener<CategoriesBean>() {
            @Override
            public void onSuccess(CategoriesBean categoriesBean) {
                view.shopCategorys(categoriesBean);
            }

            @Override
            public void onFail(String s, int code) {
                view.showErro(s, -1);
            }
        });
    }

    @Override
    public void showShopDownStairs(int page, int size, String longitude, String latitude, String message, String mainBusinessId, String limitDistance, int sort, int type) {
        nearShopModel.showShopDownStairs(page, size, longitude, latitude, message, mainBusinessId, limitDistance, sort, new OnLoadListener<ShopDownStairsBean>() {
            @Override
            public void onSuccess(ShopDownStairsBean shopDownStairsBean) {
                view.shopDownStairsData(shopDownStairsBean, type);
            }

            @Override
            public void onFail(String s, int code) {
                view.showErro(s, type);
            }
        });
    }
}
